using CapHttp.Core;
using CapHttp.Producer.Worker;
using DotNetCore.CAP;
using DotNetCore.CAP.Internal;

var builder = Host.CreateDefaultBuilder(args);
IHost host = builder
    .ConfigureServices((context, services) =>
    {
        services.Configure<CapHttpOptions>(context.Configuration.GetSection("CapHttp"));
        services.AddCap(o =>
        {
            o.UseHttpTransport();
            o.UsePostgreSql(context.Configuration.GetConnectionString("db")!);
        });
        services.BuildServiceProvider().GetService<IBootstrapper>().BootstrapAsync();
        services.AddHostedService<Worker>();
    })
    .Build();

await host.RunAsync();